/* eslint-disable eqeqeq */
/**
 * 表格配置
 * 用户管理 user-manage
 */
import userStore from '@/store/modules/user'

const nameId = () => {
  const { userId = '' } = userStore.state
  return userId
}

const headerConfig = {
  'user-manage': [
    {
      prop: 'avatarUrl',
      name: '头像',
      componentCell: 'cellImage'
    },
    {
      prop: 'fullName',
      name: '姓名',
      minWidth: 100
    },
    {
      prop: 'userName',
      name: '用户名',
      minWidth: 100
      // sortable: 'custom'
    },
    {
      prop: 'deptName',
      name: '所属机构',
      minWidth: 100
    },
    {
      prop: 'roleName',
      name: '功能角色',
      minWidth: 100
    },
    {
      prop: 'rangeName',
      name: '数据角色',
      minWidth: 140
    },
    {
      prop: 'postName',
      name: '岗位',
      minWidth: 100
    },
    {
      prop: 'mobilePhone',
      name: '手机号码',
      minWidth: 100
    },
    {
      prop: 'email',
      name: '邮箱',
      minWidth: 100
    },
    {
      prop: 'statusName',
      name: '状态',
      minWidth: 100,
      componentCell: 'CellSwitch',
      authId: 'grass-core:user:enableOrDisable',
      switchConfig: {
        valueTypeProp: 'code',
        dataProp: 'status',
        activeCode: 1,
        activeName: '启用',
        inactiveCode: 2,
        inactiveName: '禁用',
        switchPath: 'userManage.enableOrDisable',
        switchParamsProp: { id: 'id' }
      }
    },
    // {
    //   prop: 'delFlagName',
    //   name: '删除标识',
    //   minWidth: 100,
    //   dataTdStyle: {
    //     dataProp: 'delFlagName',
    //     '已删除': { color: '#F56C6C' }
    //   }
    // },
    {
      name: '操作',
      width: 200,
      fixed: 'right',
      thStyle: { 'text-align': 'left' },
      operateList: [
        {
          type: 'btnText',
          label: '详情',
          id: 'user-manage-detail',
          authId: 'grass-core:user:search',
          isMore: true,
          config: {
            type: 'text'
          }
        },
        {
          type: 'btnText',
          label: '编辑',
          id: 'user-manage-edit',
          authId: 'grass-core:user:update',
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        },
        {
          type: 'btnText',
          label: '分配功能角色',
          id: 'user-manage-role',
          authId: 'grass-core:user:allotRole',
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        },
        {
          type: 'btnText',
          label: '分配数据角色',
          id: 'user-manage-rangerole',
          authId: 'grass-core:user:allotDataRangeRole',
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        },
        {
          type: 'btnText',
          label: '重置密码',
          id: 'user-manage-password',
          authId: 'grass-core:user:resetPassword',
          isMore: true,
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        },
        {
          type: 'btnText',
          label: '删除',
          id: 'user-manage-delete',
          authId: 'grass-core:user:deleteById',
          isMore: true,
          style: { color: '#f74a5c' },
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        },
        {
          type: 'btnText',
          label: '永久删除',
          authId: 'grass-core:user:thoroughDelete',
          id: 'user-manage-thoroughDelete',
          isMore: true,
          style: { color: '#f74a5c' },
          config: {
            type: 'text'
          },
          hidden: (val) => {
            return val.id == nameId()
          }
        }
      ]
    }
  ]
}

export default {}
export { headerConfig }
